
import request from '../utils/request'

// 添加文章类型
export function addArticleType(data){
    return request.post('/articletype',data)
}

//获取所有文章类型
export function getType(){
    return request.get('/articletype')
}

//改变文章类型状态
export function enableType(id,data){
    return request.post(`/articletype/isenable/${id}`,data)
}

//修改文章类型名称
export function modArticle(id,data){
    return request.put(`/articletype/${id}`,data)
}


//获取已启用的文章类型
export function getEnbalType(){
    return request.get('/article/type')
}

// 上传文章图片
export function addPicture(file){
    return request.post(`/article/addpic`,file,{"Content-Type":" multipart/form-data"});
}

//删除文章图片
export function deletePicture(file){
    return request.put(`/article/deletepic`,file);
}

//创建文章
export function addArticle(data){
    return request.post(`/article/add`,data);
}

//添加文章封面
export function addArticlePic(file){
    return request.put(`/article/addpicture`,file,{"Content-Type":" multipart/form-data"});
}


//获取所有未发布的文章
export function getAllArticle(params){
    return request.get('/article/allnotpublish',{params:params})
}

//获取当前文章Id的文章
export function getArticleById(id){
    return request.get(`/article/getarticle/${id}`)
}


//修改文章封面
export function updateArticlePic(id,file){
    return request.put(`/article/updatepic/${id}`,file,{"Content-Type":" multipart/form-data"});
}

//修改文章
export function updateArticle(id,file){
    return request.put(`/article/update/${id}`,file);
}


//删除文章封面图片
export function deleteArticlePicture(file){
    return request.put(`/article/deleteartpic`,file);
}

//删除文章
export function deleteArticle(id){
    return request.post(`/article/delete/${id}`);
}

//发布文章/article/publish/{id}
export function publishArticle(id){
    return request.post(`/article/publish/${id}`);
}

//查找已发布文章
export function getAllPublishArticle(params){
    return request.get('/article/allpublish',{params:params})
}

//编辑是否推荐文章
export function isRecommendArticle(id,data){
    return request.post(`/article/isrecommend/${id}`,data);
}

//撤回已发布文章
export function cancelPublishArticle(id){
    return request.post(`/article/cancel/${id}`);
}

//查找相应id文章的全部内容
export function getArticleDetail(id){
    return request.get(`/article/detail/${id}`);
}